using ASP;
using HoWave.Alipay;
using HoWave.Common;
using HoWave.Web;
using HoWave.Web.Shop.Member;
using System;
using System.Collections.Generic;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.WebControls;
public class Member_AddAccount : Member, IRequiresSessionState
{
	protected DropDownList PayType;
	protected TextBox TxtMoney;
	protected Button Button1;
	protected Button Button2;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.IsPostBack)
		{
			decimal num = Text.ToDecimal(Fetch.Get("Money"));
			if (num <= 0m)
			{
				this.WriteErrMsg("", Language.GetMemberMsg("Voucher/MoneyErr", new string[0]), "");
			}
			num = decimal.Round(num, 2);
			this.TxtMoney.Text = num.ToString();
		}
	}
	protected void BindPayType()
	{
	}
	protected void Button1_Click(object sender, EventArgs e)
	{
		string text = this.config["AlipayPartnerID"].ToString().Trim();
		if (this.PayType.SelectedIndex == -1 || this.PayType.SelectedValue == "" || this.PayType.SelectedValue == "0")
		{
			this.WriteErrMsg("", "请选择通道！", "");
		}
		int num = Convert.ToInt32(this.PayType.SelectedValue);
		decimal num2 = Text.ToDecimal(this.TxtMoney.Text);
		if (num2 <= 0m)
		{
			this.WriteErrMsg("", Language.GetMemberMsg("Voucher/MoneyErr", new string[0]), "");
		}
		num2 = decimal.Round(num2, 2);
		if (num <= 0)
		{
			this.WriteErrMsg("", Language.Get("Common/NotData"), "");
		}
		OnlinePaySeting onlinePaySeting = new OnlinePaySeting(this.conn);
		if (num == 1)
		{
		}
		string payNum = DateTime.Now.ToString("yyyyMMddhhmmss") + Text.MakePassword(2);
		PayOnline payOnline = new PayOnline(this.conn);
		if (!payOnline.Add(base.user.UserID, base.user.UserName, 0, payNum, num, num2, num2, "", ""))
		{
			this.WriteErrMsg("", Language.Get("Common/Fail", ""), "");
		}
		string value = DateTime.Now.ToString("yyyyMMddhhmmss") + Text.MakePassword(2);
		string value2 = "在线充值";
		string value3 = "在线充值";
		string value4 = this.TxtMoney.Text.Trim();
		string value5 = "";
		string value6 = "";
		string value7 = "";
		string value8 = "";
		string value9 = "";
		string value10 = "";
		string value11 = "";
		string value12 = "";
		string value13 = "";
		string value14 = text;
		string value15 = this.config["AlipayEmail"].ToString().Trim();
		string value16 = this.config["AlipayKey"].ToString().Trim();
		string value17 = this.config["SiteUrl"].ToString().Trim() + "PayReturn/AliPay/Recharge/recharge_return_url.aspx";
		string value18 = this.config["SiteUrl"].ToString().Trim() + "PayReturn/AliPay/Recharge/recharge_notify_url.aspx";
		SortedDictionary<string, string> sortedDictionary = new SortedDictionary<string, string>();
		sortedDictionary.Add("partner", value14);
		sortedDictionary.Add("key", value16);
		sortedDictionary.Add("seller_email", value15);
		sortedDictionary.Add("return_url", value17);
		sortedDictionary.Add("notify_url", value18);
		sortedDictionary.Add("payment_type", "1");
		sortedDictionary.Add("show_url", value9);
		sortedDictionary.Add("out_trade_no", value);
		sortedDictionary.Add("subject", value2);
		sortedDictionary.Add("body", value3);
		sortedDictionary.Add("total_fee", value4);
		sortedDictionary.Add("paymethod", value5);
		sortedDictionary.Add("defaultbank", value6);
		sortedDictionary.Add("anti_phishing_key", value7);
		sortedDictionary.Add("exter_invoke_ip", value8);
		sortedDictionary.Add("extra_common_param", value10);
		sortedDictionary.Add("buyer_email", value11);
		sortedDictionary.Add("royalty_type", value12);
		sortedDictionary.Add("royalty_parameters", value13);
		Service service = new Service();
		string s = service.Create_direct_pay_by_user(sortedDictionary);
		base.Response.Write(s);
	}
}
